import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import '../widgets/shadow_text.dart';

import '../model/cartoon_model.dart';
import '../utils/utils.dart';

class CartoonIntro extends StatelessWidget {
  final CartoonModel cartoon;

  final Color? dominantColor;

  const CartoonIntro({super.key, required this.cartoon, required this.dominantColor});

  @override
  Widget build(BuildContext context) {
    final useNum = Utils.formatNumber(cartoon.useNum ?? 0);
    final fansNum = Utils.formatNumber(cartoon.fansNum ?? 0);
    final tplNum = Utils.formatNumber(cartoon.tplNum ?? 0);

    return Stack(children: [
      Padding(
        padding: const EdgeInsets.symmetric(horizontal: 10),
        child: Column(mainAxisAlignment: MainAxisAlignment.end, children: [
          Row(
            children: [
              Container(
                decoration: BoxDecoration(
                  border: Border.all(color: Colors.white, width: 2),
                  borderRadius: BorderRadius.circular(22),
                ),
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(20),
                  child: CachedNetworkImage(
                    height: 40,
                    width: 40,
                    fadeInDuration: const Duration(seconds: 0),
                    fadeOutDuration: const Duration(seconds: 0),
                    fit: BoxFit.cover,
                    imageUrl: cartoon.avatar,
                  ),
                ),
              ),
              const SizedBox(width: 10),
              Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [ShadowedText(cartoon.name, style: const TextStyle(color: Colors.white, fontSize: 18)), ShadowedText("@${cartoon.user!.nickname} 创作", style: const TextStyle(color: Colors.white70, fontSize: 13))],
              )
            ],
          ),
          const SizedBox(height: 20),
          SizedBox(
            width: double.infinity,
            child: ShadowedText(
              cartoon.summary,
              maxLines: 2,
              overflow: TextOverflow.ellipsis,
              softWrap: true,
              style: TextStyle(color: Colors.white.withOpacity(0.84), fontSize: 15),
            ),
          ),
          SizedBox(height: cartoon.summary.isNotEmpty ? 20 : 0),
          Row(
            children: [
              Column(
                children: [
                  ShadowedText(useNum, style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600)),
                  const ShadowedText("总互动", style: TextStyle(color: Colors.white60, fontSize: 13)),
                ],
              ),
              const SizedBox(width: 10),
              Column(
                children: [
                  ShadowedText(fansNum, style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600)),
                  const ShadowedText("粉丝", style: TextStyle(color: Colors.white60, fontSize: 13)),
                ],
              ),
              const SizedBox(width: 10),
              Column(
                children: [
                  ShadowedText(tplNum, style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600)),
                  const ShadowedText("内容", style: TextStyle(color: Colors.white60, fontSize: 13)),
                ],
              )
            ],
          ),
          const SizedBox(height: 20),
        ]),
      ),
    ]);
  }
}
